import type { FormInstance } from 'element-plus';

export const checkFn = async (
  formEl: FormInstance | undefined
): Promise<boolean | null> => {
  if (!formEl) return null;
  return await formEl.validate((valid, fields) => {
    if (valid) return true;
    return false;
  });
};

export const connectObj = (obj1: any, obj2: any) => {
  Object.keys(obj2).forEach((item) => {
    if (!obj2[item]) return;
    obj1[item] = obj2[item];
  });
  return obj1;
};
